﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.Common;
using ZX.DBModule;
using ZX.BLL.Extend;
using System.Text;
using ZX.EHR.Library;
using ZX.CRM.Bussiness;
using ZX.SYS.Library;
using ZX.CRM.Library;
using commonDal = ZX.WebApp.Extend.AjaxData;
using System.Data;

namespace ZX.WebApp.DeskTop
{
    public partial class CustomType : BasePage
    {
        BCrmReport BReport = new BCrmReport();
        BTCrmCustomer bll = new BTCrmCustomer();
        protected void Page_Load(object sender, EventArgs e)
        {
            getdt();
        }

        private int getPowerType
        {
            get
            {
                int powertype = 0;
                if (Request["PowerType"] == null || Request["PowerType"] == "" || Request["PowerType"] == "0")
                    powertype = 0;
                else
                    powertype = 1;
                return powertype;
            }
        }

        public void getdt()
        {
            DataSet myDataSet = new DataSet();
            myDataSet.DataSetName = "DsCrmCustomerInfo";
            BaseBussnies deptUserPost = new BaseBussnies();
            deptUserPost.entity = new V_DatUserPostDept();
            IList<V_DatUserPostDept> IDatUserPostDept = deptUserPost.GetEntitys<V_DatUserPostDept>(" UseriD='" + this.UserId.ToString() + "'");
            DataTable TypeDataTable = new DataTable();
            bool bl = false;
            if (IDatUserPostDept != null)
            {
                TypeDataTable = BReport.ReturnTableTypeNameDeptID(IDatUserPostDept[0].DeptID, getPowerType);
                if (TypeDataTable != null)
                {
                    Repeater1.DataSource = TypeDataTable;
                    Repeater1.DataBind();
                }
                else
                    bl = true;
                this.IsDept.Value = IDatUserPostDept[0].DeptID.ToString();
            }
            else
            {
                TypeDataTable = BReport.ReturnTableTypeName(new Guid(this.UserId.ToString()),getPowerType);
                if (TypeDataTable == null)
                    bl = true;
                else
                {
                    Repeater1.DataSource = TypeDataTable;
                    Repeater1.DataBind();
                }
                this.IsDept.Value = "0";
            }
            if (bl)
            {
                Label1.Visible = true;
                Label1.Text = "没有数据可显示！";
            }
        }
        /// <summary>
        /// 当前用户ID
        /// </summary>
        public string strUserId
        { get { return this.UserId.ToString(); } }
    }
}